"use client";
import React, { useMemo, useState } from "react";
import type { MenuProps, MenuTheme } from 'antd';
import { Menu, Switch } from 'antd';
import { usePathname } from 'next/navigation';
import { useRouter } from "next/navigation";
export default function Menus(props: any) {
  const router = useRouter();
  const params = usePathname()
  const keys=useMemo(()=>{
    if(params.split('/').length >= 3){
      return ['/'+params.split('/')[2]]
    }else{
      return ['home']
    }
  },[params])
  return (
    <Menu
      theme={'light'}
      onClick={(v)=>{
        router.push(props.url+"/"+v.key)
      }}
      style={{ width: 160 }}
      defaultOpenKeys={['/home']}
      selectedKeys={keys}
      mode="inline"
      items={props.items}
    />
  );
}
